<?php
namespace app\common\service;

use think\facade\Db;

class Money extends Base {
    static $AUTH_CHECK = true; //默认必须登录
    public function moneylog(){
        $money_type = input('money_type')?:'money';
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $user_money = Db::name('wallet')->where('user_id',$user_id)->value($money_type);
        $field = '*';
        $map = [];
        $map['user_id'] = $this->user_id;
        $lists = Db::name($money_type.'_log')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $lists->offsetSet($k,$v);
            }
        }
        $wallet_names = logic('Wallet')->getName();
        $wallet_name = $wallet_names[$money_type];

        $tx_config = tpCache('wallet.tx_'.$money_type);
        $transfer = 0;
        $withdraw = $tx_config['status']??0;
        $recharge = 0;
        if($money_type=='money'){
            $recharge = 1;
            $transfer = 1;
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists,
            'user_money' => $user_money,
            'wallet_name' => $wallet_name,
            'transfer' => $transfer,
            'withdraw' => $withdraw,
            'recharge' => $recharge,
        ];
        return $result;
    }
    //转账设置
    public function transfer_set(){
        $user_id = $this->user_id;
        $wallet_names =  logic('Wallet')->getName();
        $set_id = input('set_id');
        if(!$set_id){
            $set_id = Db::name('transfer_set')->where('status',1)->order('id asc')->value('id');
        }
        if($set_id){
            $set = Db::name('transfer_set')->where(['status'=>1,'id'=>$set_id])->find();
            $user_money = Db::name('wallet')->where('user_id',$user_id)->value($set['from']);
            $wallet_name = $wallet_names[$set['from']];
        }else{
            $user_money = Db::name('wallet')->where('user_id',$user_id)->value('money');
            $wallet_name = $wallet_names['money'];
        }
        $transfer_set = Db::name('transfer_set')->where('status',1)->order('id asc')->select()->toArray();
        array_unshift($transfer_set,['id'=>0,'title'=>'选择转账方式']);
        $result = [
            'status' => true,
            'msg' => '',
            'user_money' => $user_money,
            'transfer_set' => $transfer_set,
            'wallet_name' => $wallet_name,
            'set_id' => $set_id
        ];
        return $result;
    }
    public function transfer(){
        $username = input('username');
        $money = input('money');
        $paypwd = input('paypwd');
        if($this->user['paypwd']){
            if (encrypt($paypwd) != $this->user['paypwd']){
                return [
                    'status' => 0,
                    'msg' => '支付密码错误'
                ];
            }
        }else{
            Db::name('users')->where('user_id',$this->user_id)->update(['paypwd'=>encrypt($paypwd)]);
        }
        $to_user = Db::name('users')->where('user_id|username',$username)->find();
        if(!$to_user){
            $result = [
                'status' => false,
                'msg' => '会员不存在',
            ];
            return $result;
        }
        if($money<=0){
            $result = [
                'status' => false,
                'msg' => '请输入正确转账金额',
            ];
            return $result;
        }
        $to_money = $money;
        $set_id = input('set_id')?:0;
        $set_info = Db::name('transfer_set')->where('id',$set_id)->find();
        if(empty($set_info)){
            $result = [
                'status' => false,
                'msg' => '请选择转账类型',
            ];
            return $result;
        }
        if($set_info['tome']==0){
            //转给他人
            if($this->user_id==$to_user['user_id']){
                $result = [
                    'status' => false,
                    'msg' => '不可以转给自己',
                ];
                return $result;
            }
        }else{
            //转给他人
            if($this->user_id!=$to_user['user_id']){
                $result = [
                    'status' => false,
                    'msg' => '不可以转给他人',
                ];
                return $result;
            }
        }
        //手续费比例
        $tax_bili = $set_info['fee'];
        //手续费来源
        $tax_type = $set_info['fee_type'];
        $tax = bcmul($money,$tax_bili/100,2);
        if($tax_type==0){
            //额外货币
            $money = bcadd($money,$tax,2);
        }else{
            //转出金额中扣除
            $to_money = bcsub($money,$tax,2);
        }
        //转换比例
        $changebl = $set_info['changebl']>0?$set_info['changebl']:1;
        $to_money = bcmul($to_money,$changebl,2);
        $user = Db::name('users')->where('user_id',$this->user_id)->find();
        Db::startTrans();
        $rs=qianbao($this->user_id,-$money,$set_info['from'],'转赠','转给'.$to_user['username'],0,1);
        if(!$rs['status']){
            Db::rollback();
            $result = [
                'status' => false,
                'msg' => $rs['msg'],
            ];
            return $result;
        }
        $rs=qianbao($to_user['user_id'],$to_money,$set_info['to'],'转赠',$user['username'].'转入',0,1);
        if(!$rs['status']){
            Db::rollback();
            $result = [
                'status' => false,
                'msg' => $rs['msg'],
            ];
            return $result;
        }
        //记录转账日志
        $log = [];
        $log['user_id'] = $user['user_id'];
        $log['username'] = $user['username'];
        $log['to_user_id'] = $to_user['user_id'];
        $log['to_username'] = $to_user['username'];
        $log['money'] = $money;
        $log['tax'] = $tax;
        $log['to_money'] = $to_money;
        $log['from'] = $set_info['from'];
        $log['to'] = $set_info['to'];
        $log['w_time'] = time();
        Db::name('transfer_log')->insert($log);
        Db::commit();
        $result = [
            'status' => true,
            'msg' => '转账成功',
        ];
        return $result;
    }

    /**
     * @return array
     * @throws \think\exception\DbException
    CREATE TABLE `sy_transfer_set` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` varchar(100) DEFAULT '',
    `from` varchar(20) NOT NULL DEFAULT '',
    `to` varchar(20) NOT NULL DEFAULT '',
    `tome` tinyint(1) NOT NULL DEFAULT '0',
    `fee` decimal(12,2) NOT NULL DEFAULT '0.00',
    `fee_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0额外1转出金额',
    `changebl` decimal(12,2) DEFAULT '0.00',
    `max` decimal(12,2) DEFAULT '0.00',
    `min` decimal(12,2) DEFAULT '0.00',
    `beishu` int(11) DEFAULT '0',
    `status` tinyint(1) NOT NULL DEFAULT '1',
    `net` varchar(20) DEFAULT '',
    `w_time` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
     */
    public function transfer_log(){
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $user_money = Db::name('wallet')->where('user_id',$user_id)->value('money');
        $field = '*';
        $map = [];
        $map['user_id'] = $this->user_id;
        $lists = Db::name('transfer_log')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        $wallet_names = logic('Wallet')->getName();
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $v['from_name'] = $wallet_names[$v['from']];
                $v['to_name'] = $wallet_names[$v['to']];
                $lists->offsetSet($k,$v);
            }
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists->items(),
            'user_money' => $user_money
        ];
        return $result;
    }
    //提现设置
    public function withdraw_set(){
        $user_id = $this->user_id;
        $money_type = input('money_type')?:'money';
        $field = 'u.*,w.'.$money_type.' as money';
        $userinfo = Db::name('users')
            ->alias('u')
            ->join('wallet w','w.user_id=u.user_id')
            ->where('u.user_id',$user_id)
            ->field($field)
            ->find();
        $sysset = [
            'withdraw_weixin' => 1,
            'withdraw_aliaccount' => 1,
            'withdraw_bankcard' => 1,
            'withdraw_adapay' => 1
        ];
        $result = [
            'status' => true,
            'msg' => '',
            'userinfo' => $userinfo,
            'sysset' => $sysset
        ];
        return $result;
    }
    public function withdraw(){

        $money_type = input('money_type')?:'money';
        $config = tpCache('wallet.tx_'.$money_type);
        if($config['status']==0){
            return ['status'=>0,'msg'=>'提现功能未开启'];
        }
        if(!empty($config['withdraw_date'])){
            $withdraw_date = explode(',',$config['withdraw_date']);
            $day = date('d');
            if(!in_array($day,$withdraw_date) && !in_array(intval($day),$withdraw_date)){
                return ['status'=>0,'msg'=>'每月'.$config['withdraw_date'].'可以提现'];
            }
        }
//        if(isset($config['week'])){
//            $week=date('w');
//            if(in_array($week,$config['week'])){
//                $memosss ='';
//                foreach($config['week'] as $w){
//                    if($w==0)$w=7;
//                    $memosss.=','.$w;
//                }
//                $this->error('每周的'.trim($memosss,',').'不能兑换');
//            }
//        }

        //判断是否有正在进行中的
        $have = Db::name("withdraw_log")->where(['user_id'=>$this->user_id,'status'=>0])->find();
        if($have){
            $result = [
                'status' => false,
                'msg' => '您已经有兑换记录，正在审核中',
            ];
            return $result;
        }

        $post = I('post.');
        $money=floatval($post['money']);
        $password2=trim($post['paypwd']);

        if(!$money || $money<=0) {
            $result = [
                'status' => false,
                'msg' => '请输入正确的兑换金额',
            ];
            return $result;
        }

        //到账方式
        $dz_type = $post['paytype'];;//$post['dz_type'];
        $address = '';
        switch($dz_type){
            case "wechat":
                if($this->user['weixin']==''){
                    return ['status'=>0,'msg'=>'请先绑定微信'];
                }
                break;
            case "alipay":
                if($this->user['aliaccount']=='' || $this->user['aliaccountname']==''){
                    return ['status'=>0,'msg'=>'请先绑定支付宝'];
                }
                break;
            case "bank":
                if($this->user['bank_name']=='' || $this->user['bank_huming']=='' || $this->user['bank_card']==''){
                    return ['status'=>0,'msg'=>'请先完善银行卡信息'];
                }
                break;
            default:
                return ['status'=>0,'msg'=>'请选择到账方式'];
        }

        if($password2=='') {
//            $result = [
//                'status' => false,
//                'msg' => '请输入支付密码',
//            ];
//            return $result;
        }
        if($this->user['paypwd']=="") {
//            $result = [
//                'status' => false,
//                'msg' => '请先设置支付密码',
//                'url' => ''
//            ];
//            return $result;
        }
        if(encrypt($password2) != $this->user['paypwd']){
//            $result = [
//                'status' => false,
//                'msg' => '支付密码错误',
//                'url' => ''
//            ];
//            return $result;
        }


        if($money>$config['max'] && $config['max']>0) {
            $result = [
                'status' => false,
                'msg' => '每次兑换金额不能大于'.$config['max'],
                'url' => ''
            ];
            return $result;
        }
//        if($config['beishu']>0) {
//            if(($money%$config['beishu'])!=0) {
//                $result = [
//                    'status' => false,
//                    'msg' => "兑换金额必须是".$config['beishu']."的整数倍",
//                    'url' => ''
//                ];
//                return $result;
//            }
//        }
        if($money<$config['min']) {
            $result = [
                'status' => false,
                'msg' => '兑换额度不能小于'.$config['min'],
                'url' => ''
            ];
            return $result;
        }

        $fee=0;$total=$price=$money;
        if($config['fee']){
            $fee=$money*$config['fee']/100;
            //额外扣
            if($config['fee_type']==1){
                $total+=$fee;
            }else{
                $price-=$fee;
            }
        }
        $changebl = $config['changebl']>0?$config['changebl']:1;
        $realprice = bcmul($price,$changebl,2);
        if(($money_type=='shouyi' || $money_type=='shouyi2') && $dz_type=='usdt'){
            $realprice = $price;
        }

        if($this->user[$money_type]<$total) {
            $result = [
                'status' => false,
                'msg' => '余额不足，不能兑换',
                'url' => ''
            ];
            return $result;
        }


        Db::startTrans();
        $result=qianbao($this->user_id,-$total,$money_type,'兑换',$this->wallet[$money_type].'钱包兑换');
        if($result['status']) {
            $data=array();
            $data['username']=$this->user['username'];
            $data['user_id']=$this->user_id;
            $data['money']=$money;
            $data['fee']=$fee;
            $data['price']=$realprice;
            $data['status']=0;
            $data['addtime']=time();
            $data['tx_type']=$money_type;
            $data['bank_name'] = $this->user['bank_name'];
            $data['bank_card'] = $this->user['bank_card'];
            $data['realname'] = $this->user['bank_huming'];
            $data['weixin'] = $this->user['weixin'];
            $data['zhifubao'] = $this->user['aliaccount'];
            $data['uadd'] = $address;
            $data['dz_type']=$dz_type;
            $data['total'] = $total;
            $rss=Db::name("withdraw_log")->add($data);
            if($rss) {
                Db::commit();
                $result = [
                    'status' => true,
                    'msg' => '兑换申请成功，请等待平台审核！',
                    'url' => ''
                ];
                return $result;
            }else{
                Db::rollback();
                $result = [
                    'status' => false,
                    'msg' => '兑换失败，更新兑换记录失败',
                    'url' => ''
                ];
                return $result;
            }
        }else{
            Db::rollback();
            $result = [
                'status' => false,
                'msg' => '兑换失败'.$result['msg'],
                'url' => ''
            ];
            return $result;
        }
    }
    public function withdraw_log(){
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $user_money = Db::name('wallet')->where('user_id',$user_id)->value('money');
        $field = '*';
        $map = [];
        $map['user_id'] = $this->user_id;
        $lists = Db::name('withdraw_log')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        $wallet_names = logic('Wallet')->getName();
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $v['wallet_name'] = $wallet_names[$v['tx_type']];
                $lists->offsetSet($k,$v);
            }
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists->items(),
            'user_money' => $user_money
        ];
        return $result;
    }
    //充值设置
    public function recharge_set(){
        $user_id = $this->user_id;
        $userinfo = Db::name('users')
            ->alias('u')
            ->join('wallet w','w.user_id=w.user_id')
            ->where('u.user_id',$user_id)
            ->field('u.*,w.money')
            ->find();
        $qianbao = logic('Wallet')->getCz(1);
        //获取支付方式
        $pay = logic('Wallet')->getOnlinePay();
        $rtdata = [];
        if($pay['status']){
            $rtdata['paymentList'] = $pay['result']['pay'];
            $rtdata['bank_img'] = $pay['result']['bank_img'];
            $rtdata['bankCodeList'] = $pay['result']['bankcode'];
        }else{
            return ['status'=>0,'msg'=>$pay['msg']];
        }

        $rtdata['userinfo'] = $userinfo;
        $rtdata['giveset'] = [];
        $rtdata['shuoming'] = tpCache('shop.recharge_desc');
        return ['status'=>true,'data'=>$rtdata];
    }
    public function recharge(){
        $money_type = 'money';
        $money = input('money');

        Db::startTrans();
        //插入充值记录
        $data = [];
        $data['user_id'] = $this->user_id;
        $data['username'] = $this->user['username'];
        $data['money'] = $money;
        $data['money_type'] = $money_type;
        $data['w_time'] = time();

        $rs = Db::name('recharge_log')->insertGetId($data);
        if(!$rs){
            Db::rollback();
            return  ['status'=>false,'msg'=>'失败'];
        }

        Db::commit();
        return  ['status'=>true,'order_id'=>$rs,'data_tbl'=>'recharge_log'];

    }

    public function scorelog(){
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $user_money = Db::name('wallet')->where('user_id',$user_id)->value('score');
        $field = '*';
        $map = [];
        $map['user_id'] = $this->user_id;
        $lists = Db::name('score_log')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $lists->offsetSet($k,$v);
            }
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists,
            'user_money' => $user_money
        ];
        return $result;
    }

    public function recharge_offline(){
        if (IS_POST) {
            $post = input();
            $post['money'] = floatval($post['money']);
            if($post['money']<=0){
                $this->error('请输入充值金额');
            }
            $have = Db::name('huikuan')->where(['user_id'=>$this->user_id,'status'=>0])->find();
            if($have){
                return ['status'=>0,'msg'=>'您已经有一笔记录，正在审核中'];
            }

            if(!$post['dk_time'] || !$post['dk_name']){
                return ['status'=>0,'msg'=>'请完善信息'];
            }

            $content_pic = input('content_pic/a');
           if(empty($content_pic)){
               return ['status'=>0,'msg'=>'请上传付款截图'];
                //$this->error('请上传付款截图');
            }
            $content_pic = implode(',',$content_pic);

            $data=array();
            $data['username']=$this->user['username'];
            $data['user_id']=$this->user_id;
            $data['money_type'] = input('money_type');
            $data['money']=$post['money'];
            $data['status']=0;
            $data['addtime']=time();
            $data['dk_img'] = $content_pic;
            $data['dk_name'] = $post['dk_name'];
            $data['dk_time'] = $post['dk_time'];
            $data['sk_qrcode'] = tpCache('shop_info.hksk');
            $data['sk_name'] = tpCache('shop_info.skname');
            $data['memo']=$post['memo'];

            $rss=Db::name("huikuan")->insert($data);
            if($rss) {
                return ['status'=>1,'msg'=>'申请成功，请耐心等待审核'];
            }else{
                return ['status'=>0,'msg'=>'添加下线充单记录失败'];
            }

        }else{
            $user_id = $this->user_id;
            $userinfo = Db::name('users')
                ->alias('u')
                ->join('wallet w','w.user_id=u.user_id')
                ->where('u.user_id',$user_id)
                ->field('u.*,w.money')
                ->find();
            $qianbao = logic('Wallet')->getCz(1);
            //获取支付方式
            $pay = logic('Wallet')->getOnlinePay();
            $rtdata = [];
            if($pay['status']){
                $rtdata['paymentList'] = $pay['result']['pay'];
                $rtdata['bank_img'] = $pay['result']['bank_img'];
                $rtdata['bankCodeList'] = $pay['result']['bankcode'];
            }else{
                //return ['status'=>0,'msg'=>$pay['msg']];
            }
            $wallet_name = logic('Wallet')->getName('money');

            $rtdata['wallet_name'] = $wallet_name;
            $rtdata['userinfo'] = $userinfo;
            $rtdata['giveset'] = [];
            $rtdata['shuoming'] = tpCache('shop.recharge_offline_desc');
            return ['status'=>true,'data'=>$rtdata];
        }
    }
    public function huikuan_log(){
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $user_money = Db::name('wallet')->where('user_id',$user_id)->value('money');
        $field = '*';
        $map = [];
        $map['user_id'] = $this->user_id;
        $lists = Db::name('huikuan')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $lists->offsetSet($k,$v);
            }
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists->items(),
            'user_money' => $user_money
        ];
        return $result;
    }

    public function total_shouyi_day(){
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $start = ($page-1)*$limit;
        $end = $start+15;
        $data = [];
        $time = getCurTime();
        for($i=$start; $i<=$end; $i++){
            $s_time = strtotime(date('Y-m-d',$time-$i*86400));
            $e_time = $s_time+86400;
            $map = [];
            $map['user_id'] = $this->user_id;
            $map['riqi'] = $s_time;
            $map['bonus_type'] = ['neq','reward'];
            $shouyi = Db::name('bonus_detail')->where($map)->sum('bonus');
            if($shouyi<=0){
                continue;
            }
            $data[] = [
                'date_str' => date('Y-m-d',$s_time),
                'shouyi' => $shouyi,
            ];
        }
        $values = array_filter(array_column($data,'shouyi'));
        if(count($values)<=1 && $values[0]<=0){
            return ['status'=>true,'data'=>[]];
        }

        return ['status'=>true,'data'=>$data];
    }
    public function total_shouyi(){
        $prize_arr = config('prize');
        $date_str = input('date_str');
        $user_info = Db::name('users')->where('user_id',$this->user_id)->find();
        $show_chelv = tpCache('bonus.show_chelv')?:0;
        $data = [];
        foreach($prize_arr as $prize_k=>$prize_name){
            if($prize_k=='fuwu_bonus' && $user_info['is_fuwu']!=1){
                continue;
            }

            if($prize_k=='reward'){
                continue;
            }
            $map = [];
            $map['user_id'] = $this->user_id;
            $map['bonus_type'] = $prize_k;
            if($date_str){
                $s_time = strtotime($date_str);
                $e_time = $s_time+86400;
                //$map['riqi'] = ['between',[$s_time,$e_time]];
                $map['riqi'] = $s_time;
            }
            $shouyi = Db::name('bonus_detail')->where($map)->sum('bonus');
            if($prize_k=='chelv_bonus' && $show_chelv!=1 && $shouyi<=0){
                continue;
            }
            $data[] = [
                'type' => $prize_k,
                'name' => $prize_name,
                'shouyi' => $shouyi
            ];
        }
        return ['status'=>true,'data'=>$data];
    }

    //静态释放记录
    public function shouyi_release_log(){
        $money_type = input('money_type');
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $field = 's.*,u.mobile';
        $map = [];
        $map['s.user_id'] = $user_id;
        $lists = Db::name('shouyi_release')
            ->alias('s')
            ->join('users u','s.user_id=u.user_id','left')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $v['day_num'] = bcmul($v['total_num'],$v['release_bili']/100,2);
                $lists->offsetSet($k,$v);
            }
        }

        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists,
        ];
        return $result;
    }

    //收益记录
    public function shouyi_lists(){
        $bonus_type = input('bonus_type');
        $date_str = input('date_str');
        $page = input('pagenum');
        $limit = input('limit')?:15;
        $user_id = $this->user_id;
        $field = '*';
        $map = [];
        $map['user_id'] = $user_id;
        if($bonus_type){
            $map['bonus_type'] = $bonus_type;
        }
        if($date_str){
            $s_time = strtotime($date_str);
            $map['riqi'] = $s_time;
        }
        $lists = Db::name('bonus_detail')
            ->where($map)
            ->order('id desc')
            ->field($field)
            ->paginate(15,false,['page'=>$page,'list_rows'=>$limit]);
        if($lists->total()){
            foreach($lists as $k=>$v){
                $v['w_time'] = date('Y-m-d H:i:s',$v['w_time']);
                $lists->offsetSet($k,$v);
            }
        }
        $prize_arr = config('prize');
        $bonus_name = $prize_arr[$bonus_type]??'';
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists,
            'bonus_name' => $bonus_name,
        ];
        return $result;
    }
}
